{include file="header.html"}
<script type="text/javascript">
    $(function () {

        // 添加时间
        $('#not_before').datepicker({dateFormat: 'yy-mm-dd'});
        $('#not_after').datepicker({dateFormat: 'yy-mm-dd'});
        
    });
</script>
<div id="rightTop">
    <p>{$lang.coupon_codes}</p>
    <ul class="subnav">
        <li><a class="btn1" href="index.php?app=coupon_codes">{$lang.manage}</a></li>
        <li><span>{$lang.edit}</span></li>
    </ul>
</div>

<div class="info">
    <form method="post" enctype="multipart/form-data" id="sort_form">
        <table class="infoTable">
            <tr>
                <th class="paddingT15">
                    {$lang.name}:</th>
                <td class="paddingT15 wordSpacing5">
                    <input class="infoTableFile2" id="name" name="name" value="{$coupon_codes.name}"/>
                </td>
            </tr>
            <tr>
                <th class="paddingT15">
                    {$lang.store_id}:</th>
                <td class="paddingT15 wordSpacing5">
                    <select name="store_id" id="store_id">
                        <option value="">==请选择店铺==</option>
                        <!--{foreach from=$stores key=i item=store}-->
                        <option value="{$store.store_id}"{if $i eq $coupon_codes.store_id} selected{/if}>{$store.store_name}</option>
                        <!--{/foreach}-->
                    </select>
                    <label class="field_notice">{$lang.allowed_empty}</label>  
                </td>
            </tr>

            <tr>
                <th class="paddingT15">
                    {$lang.choose_ico}:</th>
                <td class="paddingT15 wordSpacing5">
                    <input class="infoTableFile2" id="ico" type="file" name="ico" />
                    <label class="field_notice">{$lang.limit_img}</label>
                </td>
            </tr>      
            
            {if $coupon_codes.ico}
            <tr>
                <th class="paddingT15">
                </th>
                <td class="paddingT15 wordSpacing5">
                    <img src="{$coupon_codes.ico}" class="makesmall" max_width="120" max_height="90" />
                </td>
            </tr>
            {/if}            

            <tr>
                <th class="paddingT15">
                    {$lang.type}:</th>
                <td class="paddingT15 wordSpacing5">
                    <select name="type" id="type">
                        <option value="">==请选择活动类型==</option>
                        <!--{foreach from=$types key=i item=type}-->
                        <option value="{$i}"{if $i eq $coupon_codes.type} selected{/if}>{$type}</option>
                        <!--{/foreach}-->
                    </select>
                </td>
            </tr>

            <tr>
                <th class="paddingT15">
                    {$lang.value}:</th>
                <td class="paddingT15 wordSpacing5">
                    <input class="infoTableFile2" id="value" type="text" name="value" value="{$coupon_codes.value}" />
                    <label class="field_notice">{$lang.limit_number}</label>
                </td>
            </tr>        
            
            <tr>
                <th class="paddingT15">
                    {$lang.total}:</th>
                <td class="paddingT15 wordSpacing5">
                    <input class="infoTableFile2" id="total" type="number" name="total" value="{$coupon_codes.total}" />
                    <label class="field_notice">{$lang.total_tip}</label>
                </td>
            </tr>
            
            <tr>
                <th class="paddingT15">
                    {$lang.min_amount}:</th>
                <td class="paddingT15 wordSpacing5">
                    <input class="infoTableFile2" id="min_amount" type="number" name="min_amount" value="{$coupon_codes.min_amount}" />
                    <label class="field_notice">{$lang.total_tip}</label>
                </td>
            </tr>   
            
            <tr>
                <th class="paddingT15">
                    {$lang.not_before}:</th>
                <td class="paddingT15 wordSpacing5">
                    <input class="infoTableFile2" id="not_before" type="text" name="not_before" readonly value="{$coupon_codes.not_before}" />
                </td>
            </tr>      
            
            <tr>
                <th class="paddingT15">
                    {$lang.not_after}:</th>
                <td class="paddingT15 wordSpacing5">
                    <input class="infoTableFile2" id="not_after" type="text" name="not_after" readonly value="{$coupon_codes.not_after}" />
                </td>
            </tr>      
            
            <tr>
                <th class="paddingT15">
                    {$lang.enabled}:</th>
                <td class="paddingT15 wordSpacing5">
                    <input type="checkbox" name="enabled" id="enabled" {if $coupon_codes.enabled eq 1}checked{/if} value="1" />
                </td>
            </tr>              

            <tr>
                <th></th>
                <td class="ptb20">
                    <input class="formbtn" type="submit" name="Submit" value="{$lang.submit}" />
                    <input class="formbtn" type="reset" name="Submit2" value="{$lang.reset}" />
                </td>
            </tr>

        </table>
    </form>

    <div class = "bg-model" style="position:absolute;top:0%;left:0%;display:none;background:rgba(0,0,0,0.3);width:100%;height:100%;position:fixed;z-index:9999">
        <iframe src="index.php?app=coupon_codes&act=iframe&sort={$sort_type}" id="goods_page" width="90%" height="90%"></iframe>
    </div>
</div>
{include file="footer.html"}

<script>
    var goods_id = '';
    $(function () {
    })
    $(".cart-add").click(function () {
        $("iframe").contents().find(".checkitem:checked");
        $("iframe").contents().find(".checkitem:checked").each(function () {
            $(this).removeAttr('checked');
        })
        $("iframe").contents().items = '';
        $(".bg-model").fadeTo(300,1)
        //隐藏窗体的滚动条
        $("body").css({ "overflow": "hidden" });
    });

    //模态框OK按钮点击事件
    $(".bg-model-ok").click(function () {
        $(".bg-model").hide();
        //显示窗体的滚动条
        $("body").css({ "overflow": "visible" });
    }).hover(function () {
        $(this).css({ "backgroundColor": "#8CC8C8" });
    }, function () {
        $(this).css({ "backgroundColor": "#8CD4E6" });
    });
    $("#enter").click(function () {
        var items = '';
        var name = '';
        $('.checkitem:checked').each(function(){
            items += this.value + ',';
            name += $(this).attr('attr-name') + ','
        });
        items = items.substr(0, (items.length - 1));
        name = name.substr(0, (name.length - 1));
        var items_arr = items.split(',');
        var name_arr = name.split(',');
        for(var i in items_arr){
            $(".choose_goods").append('<label style="padding: 5px; border:1px solid #e3e3e3" name="goods" value="'+items_arr[i]+'">'+name_arr[i]+'</label><input type="checkbox" checked style="display: none" value="'+items_arr[i]+'" name="goods"><img style="margin-right: 10px;width:15px;height: 15px;" src="templates/style/images/close.gif" onclick="dropGoods(this' +
                ')" fieldname="mall_recommended" fieldid="{$goods.goods_id}" fieldvalue="1" title="{$lang.editable}"/>');
        }
        $('#goods_id').val($('input[name="goods"][type=checkbox]:checked').map(function(){return this.value}).get().join(','));
        $(".bg-model").hide();
        //显示窗体的滚动条
        $("body").css({ "overflow": "visible" });
    })
    function dropGoods(obj) {
        $(obj).parent().parent().remove();
        $(obj).remove();
        $('#goods_id').val($('input[name="goods"][type=checkbox]:checked').map(function(){return this.value}).get().join(','));
    }

</script>

